﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace FeatureDemo.Features.Networking
{
    public partial class RssReader : PhoneApplicationPage
    {
        public RssReader()
        {
            InitializeComponent();

        }

        void RssReader_Loaded(object sender, RoutedEventArgs e)
        {
            LoadFeed();
        }

        void webclient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                string xml = e.Result;
                _xml.Text = xml;    
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }

        private void _loadButton_Click(object sender, RoutedEventArgs e)
        {
            LoadFeed();
        }

        private void LoadFeed()
        {
            WebClient webclient = new WebClient();
            webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webclient_DownloadStringCompleted);
            webclient.DownloadStringAsync(new Uri("http://blogs.msdn.com/b/olivers/rss.aspx"));

            
        }

        string _helper;

        public string Helper
        {
            get { return _helper; }
            set { _helper = value; }
        }
    }
}